home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************/
- /* */
- /* YTARCMOVE */
- /* Copyright ©1997 by Dick Whiting */
- /* */
- /*----------------------------------------------------------------------------*/
- /* This script requires YAMTOOLS for it to work. If you don't have YAMTOOLS */
- /* you can get it on Aminet in directory comm/mail. This script allows you */
- /* to archive all selected mail to a folder. This is only really useful from */
- /* the mail list of a SEARCH. Otherwise, use YAM's normal capabilities. */
- /* */
- /* WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!! */
- /* */
- /* This one as of Yam 1.3.4 MAY be breaking some of Marcel's rules. I really */
- /* don't know. This allows you to archive FROM ANY folder TO any folder other */
- /* than INCOMING,SENT, and OUTGOING. I calculate the new name according to */
- /* what I have surmised Marcel does. No Guarantees that this is entirely */
- /* compatible with the way Marcel intended. Hope so. */
- /* */
- /* Version 1.1 of YTARCMOVE includes a test for the YAM version, which kill */
- /* this script if the YAM version is greater than 1.3.x If (and I don't */
- /* think so) there is a need for this script for later versions of YAM, then */
- /* I will rewrite it as necessary. - Dick */
- /* */
- /*----------------------------------------------------------------------------*/
- /* */
- /* Standard Disclaimer: I wrote it, it works for me, I don't guarantee */
- /* that it will do anything productive for anyone else, etc. etc. ;-) */
- /* */
- /*HOWEVER, if you DO find a use for it: I homeschool my kids and they */
- /*would love a postcard from where EVER you live. */
- /* */
- /*Instant GEOGRAPHY lesson;) */
- /* */
- /* */
- /*POSTCARDS: Dick Whiting */
- /* 28590 S. Beavercreek Rd. */
- /* Mulino, Oregon 97042 */
- /* USA */
- /* */
- /*----------------------------------------------------------------------------*/
- /* */
- /* Address Bug Reports or Comments to: */
- /* Dick Whiting <dwhiting@europa.com> */
- /* 11 March 1997 */
- /* */
- /******************************************************************************/
- /*
- $VER: 1.1 Copyright ©1997 by Dick Whiting
- $AUTHOR: Dick Whiting
- $DESCRIPTION: Archiver-Mover for use with YAMTOOLS
- */
-
- options results
- options failat 21
-
- targarch=''
- targanum=''
- targdir=''
-
- parse arg targarch ',' targanum ',' targdir
-
- /**************************************************************************/
- /* Initialize Variables */
- /**************************************************************************/
- Call MUIvars /* go define vars for MUI use */
- Call YTvars /* various values used in YT */
- Call Helpvars /* pointers into HELP guide */
- Call Localize /* vars for localizing strings*/
- Call Builtvars /* built using previous values*/
-
- Address YAMTOOLS
-
- Call CheckYam
-
- Select
- when targarch='' then do
- Call CheckMailList
- Call ArchWindow
- Call DisplayArchs
- end
- otherwise do
- Call ProcessArchs
- end
- end
-
-
- exit
-
- /**************************************************************************/
- /* Check that there is some mail to process */
- /**************************************************************************/
- CheckMailList:
-
- list ID MLST ATTRS MUIA_List_Entries
- mcnt=result
- if mcnt=0 then do
- errmsg=_text._nomail
- Call ErrorMsg
- end
-
- Return
-
- /**************************************************************************/
- /* Display list of Archives */
- /**************************************************************************/
- /* Don't allow Incoming, Outgoing, Sent as target folders */
- /**************************************************************************/
- DisplayArchs:
-
- list ID ALST ATTRS MUIA_List_Entries
- acnt=result
-
- do i=3 to acnt-1
- list ID ALST POS i
- aline=result
- if aline='' then break
- parse var aline arch ',' size ',' file ',' anum ',' rest
- liststr=arch','anum','file
- list ID ARCHF INSERT POS MUIV_List_Insert_Bottom STRING liststr
- end
-
- Return
-
- /**************************************************************************/
- /* Process Archivals */
- /**************************************************************************/
- ProcessArchs:
-
- if targanum < 3 then do
- errmsg=bo||targarch||' '||np||_text._badtarg
- Call ErrorMsg
- end
-
- window ID YTARC close
-
- infotitle=_title._info
- infotext=np||_text._inmail
- infobuttons=_text._squit1||comma||_text._squit2||comma||_text._squit3
- showbusy=TRUE
-
- Call InfoWindow
-
- list ID MLST ATTRS MUIA_List_Entries
- mcnt=result
-
- archlist.=missing
- archlist.0=0
- Updlist.=missing
- Updlist.0=0
- acnt=0
-
- /**************************************************************************/
- /* build list of mail to archive */
- /**************************************************************************/
-
- do i=0 to mcnt-1
- list ID MLST
- mline=result
- if mline='' then break
- parse var mline arch ',' from ',' subj ',' mfor ',' mnum ',' anum ',' file
- acnt=acnt+1
- anum=right(anum,6,'0')
- mnum=right(mnum,6,'0')
- Archlist.0=acnt
- Archlist.acnt=anum mnum file subj
- archlist.0=acnt
- radio ID SQUIT
- if result~=_text._squit1 then signal ProcessArchsEnd
- end
- Updlist.0=Archlist.0
-
- if acnt=0 then do
- errmsg=_text._nomail
- Call ErrorMsg
- end
-
- /**************************************************************************/
- /* sort the list in preparation */
- /**************************************************************************/
-
- if show('L','rexxtricks.library') then do /* use tricks library */
- call QSORT(archlist) /* sort by name, line number */
- end
- else do /* use QuickSort format */
- call QSORT(1, archlist.0, archlist) /* sort by name, number */
- end
-
- radio ID SQUIT
- if result~=_text._squit1 then signal ProcessArchsEnd
-
- /**************************************************************************/
- /* Loop thru mail verifying nothing has changed */
- /* do it in reverse order to keep from rearranging list */
- /**************************************************************************/
-
- do i=archlist.0 to 1 by -1 /* process in reverse order */
- radio ID SQUIT
- if result~=_text._squit1 then leave /* skip remaining & do cleanup */
- anum=word(Archlist.i,1)
- anum=strip(anum,'L','0')
- if anum='' then anum=0
- mnum=word(Archlist.i,2)
- mnum=strip(mnum,'L','0')
- if mnum='' then mnum=0
- file=word(Archlist.i,3)
- subj=subword(Archlist.i,4)
- Updlist.i=anum
- Updlist.i.1=mnum
- Updlist.i.1.1=file
- Updlist.i.1.1.1=subj
- Address YAM 'setfolder 'anum /* goto folder */
- Address YAM 'setmail 'mnum /* set to mail */
- Address YAM "getmailinfo file" /* verify filename */
- xfile=result
- fullfile=xfile /* copy complete path/fn */
- xlen=length(file)
- xfile=right(xfile,xlen)
- Address YAM "getmailinfo subject" /* verify subject */
- xsubj=result
- xsubj=translate(xsubj,' ',',')
- if file~=xfile | xsubj~=subj then do
- Updlist.i.1.1.1.1=bo||_text._error
- end
- else do
- if anum=0 then do /* use ARCHIVE cmd for Incoming */
- Address YAM "mailarchive " targanum
- Updlist.i.1.1.1.1=bo||_text._archived
- end
- else do /* Handle others */
- Call MoveIt
- end
- end
- end
-
- /**************************************************************************/
- /* Update target and source folders */
- /**************************************************************************/
-
- infotext=np||_text._updindex
- text ID STEXT LABEL infotext
-
- Address YAM 'setfolder 'targanum /* set to target folder */
- Address YAM 'mailupdate' /* update the index */
- oldarch=missing /* level break control */
- do i=1 to Updlist.0
- if Updlist.i~=oldarch then do
- Address YAM 'setfolder ' Updlist.i /* goto folder */
- Address YAM 'mailupdate' /* update the index */
- oldarch=Updlist.i
- end
- end
-
- /**************************************************************************/
- /* Update list of mail archived/moved */
- /**************************************************************************/
-
- infotext=np||_text._update
- text ID STEXT LABEL infotext
-
- do i=1 to Updlist.0 /* display status messages */
- do j=0 to mcnt-1
- list ID MLST POS j
- mline=result
- if mline='' then break
- parse var mline arch ',' from ',' subj ',' mfor ',' mnum ',' anum ',' file
- if Updlist.i=anum & Updlist.i.1=mnum then do
- if Updlist.i.1.1.1.1~=missing then arch=Updlist.i.1.1.1.1
- mline=arch||','||from||','||subj||','||mfor||','||mnum||','||anum||','||file
- list ID MLST POS j STRING mline
- iterate i
- end
- end
- end
-
- ProcessArchsEnd:
-
- window ID YTINF CLOSE
-
- Return
-
- /**************************************************************************/
- /* Find the LAST filename in the target dir, calculate new name, do a DOS */
- /* COPY command for output and a DOS delete command for the input. */
- /* !! DON'T USE 'i' as a pointer in this routine */
- /**************************************************************************/
- MoveIt:
-
- targfn=right(date('I'),5,'0')
-
- dirlist=showdir(targdir,'FILE')
- highfile='.index'
- do filecnt=1 to words(dirlist)
- if word(dirlist,filecnt) > highfile then do
- highfile=word(dirlist,filecnt)
- end
- end
-
- highname=substr(highfile,1,5)
- highext=substr(highfile,7,3)
-
- if targfn>highname then do
- highname=targfn
- highext='001'
- end
- else do
- highext=highext+1
- highext=right(highext,3,'0')
- end
-
- if highext='000' then do /* gone over 999 */
- highname=right(highname+1,5,'0') /* use next days date */
- highext='001' /* new series */
- end
-
- Address Command 'Copy ' fullfile 'TO' targdir'/'highname'.'highext 'QUIET CLONE'
- if rc=0 then do
- Updlist.i.1.1.1.1=bo||_text._moved
- Address Command 'Delete ' fullfile 'QUIET'
- end
- else do
- Updlist.i.1.1.1.1=bo||_text._error
- end
-
- Return
-
- /**************************************************************************/
- /* Make sure YAM and YAMTOOLS are running. Show YAM. */
- /**************************************************************************/
- CheckYAM:
-
- if ~show('p','YAMTOOLS') then do
- errmsg=_text._noyt
- say errmsg
- exit
- end
-
- if ~show('p','YAM') then do
- errmsg=_text._noyam
- Call ErrorMsg
- exit
- end
-
- Address YAM 'info version' /* check YAM's version */
- yamver=word(result,3)
-
- if left(yamver,3)~=goodver then do /* only 1.3.x or lower valid */
- errmsg=_text._badver||yamver
- Call ErrorMsg
- exit
- end
-
- Address YAM 'show' /* uniconify YAM's screen */
-
- Address YAM 'info SCREEN' /* get YAM's screen */
- screen=result
- if screen='' then screen='Workbench'
-
- Return
-
- /******************************************************************************/
- /* Display ERROR message and EXIT. */
- /******************************************************************************/
- ErrorMsg:
-
- window ID YTINF CLOSE
-
- request ID ERRM GADGETS _text._ok errmsg
-
- exit
-
- Return
-
- /******************************************************************************/
- /* Display list of Archives for archive target selection. */
- /******************************************************************************/
- ArchWindow:
-
- window ID YTARC TITLE _title._main,
- COMMAND '"window ID YTARC close"' PORT YAMTOOLS,
- ATTRS MUIA_Window_PublicScreen screen
-
- group
- group
- text LABEL bc||_text._selfolder
- endgroup
- group
- list ID ARCHF COMMAND '"YTArcMove.rexx %s"',
- HELP help.ARCHF NODE node.ARCHF,
- TITLE _title._archf,
- INSERT NODUP,
- ATTRS MUIA_List_Format '"BAR,P=\033r"'
- endgroup
- endgroup
-
- endwindow
-
- Return
-
- /******************************************************************************/
- /* Simple information/error message window. */
- /******************************************************************************/
- InfoWindow:
-
- window ID YTINF TITLE _title._info ATTRS MUIA_Window_PublicScreen screen,
- MUIA_Window_DepthGadget FALSE
-
- group
- group
- text ID STEXT HELP help.STEXT NODE node.STEXT LABEL infotext
- endgroup
- if showbusy then do
- group
- object CLASS '"Busy.mcc"' ATTRS MUIA_VertWeight 25
- endgroup
- end
- if infobuttons ~='' then do
- group HORIZ
- group
- space HORIZ
- endgroup
- group
- radio ID SQUIT HELP help.SQUIT NODE node.SQUIT LABELS infobuttons
- endgroup
- group
- space HORIZ
- endgroup
- endgroup
- end
- else do
- group
- space HORIZ 100
- endgroup
- end
- endgroup
- endwindow
-
- Return
-
- /******************************************************************************/
- /* MUIREXX TAGS & VARIABLES */
- /******************************************************************************/
- Muivars:
-
- MUIA_List_Format = 0x80423c0a
- MUIA_List_Entries = 0x80421654
- MUIA_VertWeight = 0x804298d0
- MUIA_Window_DepthGadget = 0x80421923
- MUIA_Window_DragBar = 0x8042045d
- MUIA_Window_PublicScreen = 0x804278e4
- MUIA_Window_SizeGadget = 0x8042e33d
-
- TRUE=1
- FALSE=0
-
- MUIV_List_Insert_Active = -1
-
- Return
- /**************************************************************************/
- /* Various values used throughout the various routines */
- /**************************************************************************/
- YTvars:
-
- goodver='1.3' /* this script is valid for YAM 1.3.x */
-
- comma=','
- missing='.'
-
- bo='\033b' /* print control BOLD */
- bc='\033b\033c' /* print control BOLD CENTER */
- nc='\033n\033c' /* print control NORM CENTER */
- np='\033n' /* print control NORM */
- nl='\n' /* print control 1 NEW LINE */
- nl2='\n\n' /* print control 2 NEW LINES */
- ct='\033c' /* print control CENTER */
- lf='\033l' /* print control LEFT ALIGN */
- rt='\033r' /* print control RIGHT ALIGN */
-
- Return
-
- /**************************************************************************/
- /* Messages, text, etc. constructed using previously defined values */
- /**************************************************************************/
- Builtvars:
-
- _title._archf='"'||bo||_col._archf1||comma||bo||_col._archf2'"'
-
- Return
-
- /**************************************************************************/
- /* Pointers into the YamTools.guide documentation */
- /**************************************************************************/
- Helpvars:
-
- node.SQUIT='7.3.'
- node.STEXT='7.3.'
- node.ARCHF='7.3.'
-
- Return
-
- /**************************************************************************/
- /* Mui Gadgets, text, msgs, etc. used in YamTools */
- /**************************************************************************/
- Localize:
-
- /*********************************/
- /* Miscellaneous info strings */
- /*********************************/
- _title._main="""YTArcMove""" /* main screen title */
- _title._info="""YTArcMove Info""" /* default title on infomsg */
- _title._user="""YTArcMove User Info""" /* title for user info screen */
-
- _text._ok="Ok" /* various OK buttons */
- _text._cancel="Cancel" /* LABEL for CANCEL button */
- _text._squit1="Continue" /* CONTINUE option on infowin */
- _text._squit2="Interrupt" /* INTERRUPT option on infowin*/
- _text._squit3="Abort" /* ABORT option on infowin */
-
- _col._archf1="Yam Folder Name" /* heading for ARCHF column 1 */
- _col._archf2="Number" /* heading for ARCHF column 2 */
-
- _text._selfolder="Select Target Folder For Archiving"
-
- _text._error="error" /* error on archiving mail */
- _text._moved="moved" /* mail has been moved */
- _text._skipped="skipped" /* skipped archiving mail */
- _text._archived="archived" /* indicate mail archived */
- _text._update="Updating Mail Status..." /* updating entries */
- _text._updindex="Updating Folder Indexes..." /* updating the indexes */
-
- _text._inmail="Doing Archiving and Moving..."
-
-
- /*********************************/
- /* Various error conditions */
- /*********************************/
-
- _text._noyam="You need YAM running to use YTArcMove" /* yam not running */
- _text._noyt="You need YAMTOOLS running to use YTArcMove" /* no yamtools */
- _text._nomail="You need to SELECT mail to Archive"
- _text._badtarg=" is not a valid target for archiving"
- _text._badver="This script is not valid for YAM "
-
- /**************************************************************************/
- /* Help Messages to display with MUI bubble facility. */
- /* */
- /* Format is simple: help.ID where ID is the id specified on the MUI */
- /* object statement. */
- /* Similar approach for accessing the .guide information using the NODE */
- /* option on the object statement. */
- /* */
- /**************************************************************************/
-
- help.SQUIT=""""""
- help.STEXT=""""""
- help.ARCHF=""""""
-
- Return
-
-
-
-